#ifndef B2D_RIGIDBODY_H
#define B2D_RIGIDBODY_H

#include "Prerequisites.h"
#include <Box2D/Box2D.h>
#include <vector>

NS_B2D_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief	Extends Box2D fixture definition to allow multiple shapes. Useful for defining a
/// 		concave shape as a single entity. Shapes will be deleted when the section is
/// 		destructed, so allocate on the heap.
////////////////////////////////////////////////////////////////////////////////////////////////////
struct B2D_API FixtureDef final
	: public b2FixtureDef
{
	std::vector<std::shared_ptr<b2Shape>> shapes;
};

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief	Rigid body definition. This a container for the Box2D body definition alongside the
/// 		data needed to define its fixtures
////////////////////////////////////////////////////////////////////////////////////////////////////
struct B2D_API RigidBodyDef final
	: public b2BodyDef
{
	std::vector<FixtureDef> fixtures;
};

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief	Rigid body helper.
////////////////////////////////////////////////////////////////////////////////////////////////////
class B2D_API RigidBody final
{
	B2D_STATIC_CLASS(RigidBody)

public:
	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// \brief	Creates a body into the provided world using the definition provided. This helper
	/// 		function creates the body and creates a ficture for every shape.
	///
	/// \param	world	The world.
	/// \param	def  	The definition of the body.
	///
	/// \return	null if it fails, else the new body.
	////////////////////////////////////////////////////////////////////////////////////////////////////
	static b2Body* createBody(b2World& world, const RigidBodyDef& def);
};

NS_B2D_END

#endif